import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

@Injectable({
  providedIn: 'root'
})
export class UnionPayManageService {
  serviceUrls = {
    queryDeveloperListUrl: '/businessUser/list', // 查询拓展员管理
    queryDeveloperDetailsUrl: '/businessUser/details', // 拓展员详情
    auditDeveloperUrl: '/businessUser/audit', // 拓展员审核

    queryMerchantListUrl: '/businessMerchant/list', // 查询商户List
    queryMerchantDetailsUrl: '/businessMerchant/details', // 查询商户详情
    auditMerchantUrl: '/businessMerchant/audit', // 商户审核

    queryAdminOptionUrl: '/businessBill/userList', // 拓展员下拉
    queryMerchantOptionUrl: '/businessBill/mchList', // 商户下拉
    queryFlowwaterListUrl: '/businessBill/list', // 查询流水
    addFlowwaterListUrl: '/businessBill/add', // 新增流水
    queryFlowwaterDetailsUrl: '/businessBillRecord/details', // 流水明细
  };

  constructor(
    private httpClient: HttpClient
  ) {}

  /**
   * ----------------------------------------------------------------
   * ****** 拓展员管理 ******
   * ----------------------------------------------------------------
   */

  // 查询拓展员
  getDeveloperList(params: any) {
    return this.httpClient.post(this.serviceUrls.queryDeveloperListUrl, params).toPromise();
  }

  // 查询拓展员详情
  getDeveloperDetails(id: string | number) {
    let url = `${this.serviceUrls.queryDeveloperDetailsUrl}/${id}`;
    return this.httpClient.get(url).toPromise();
  }

  // 拓展员审核
  auditDeveloperData(params: any) {
    return this.httpClient.post(this.serviceUrls.auditDeveloperUrl, params).toPromise();
  }

  /**
   * ----------------------------------------------------------------
   * ****** 商户管理 ******
   * ----------------------------------------------------------------
   */

  // 查询商户
  getMerchantList(params: any) {
    return this.httpClient.post(this.serviceUrls.queryMerchantListUrl, params).toPromise();
  }

  // 查询商户详情
  getMerchantDetails(id: string | number) {
    let url = `${this.serviceUrls.queryMerchantDetailsUrl}/${id}`;
    return this.httpClient.get(url).toPromise();
  }

  // 商户审核
  auditMerchantData(params: any) {
    return this.httpClient.post(this.serviceUrls.auditMerchantUrl, params).toPromise();
  }

  /**
   * ----------------------------------------------------------------
   * ****** 流水管理 ******
   * ----------------------------------------------------------------
   */

  // 拓展员下拉
  getAdminOptionData() {
    return this.httpClient.post(this.serviceUrls.queryAdminOptionUrl, {}).toPromise();
  }

  // 商户下拉
  getMerchantOptionData(id: number) {
    let url = `${this.serviceUrls.queryMerchantOptionUrl}/${id}`;
    return this.httpClient.get(url, {}).toPromise();
  }

  // 流水list
  getFlowwaterList(params: any) {
    return this.httpClient.post(this.serviceUrls.queryFlowwaterListUrl, params).toPromise();
  }

  // 新增流水
  addFlowwaterData(params: any) {
    return this.httpClient.post(this.serviceUrls.addFlowwaterListUrl, params).toPromise();
  }

  // 流水明细
  getFlowwaterDetails(params: any) {
    return this.httpClient.post(this.serviceUrls.queryFlowwaterDetailsUrl, params).toPromise();
  }
}
